﻿using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Transactions;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;

using Demo.Data;
using Demo.Data.Abstract;
using Demo.Business.EntityServices.Abstract;
using Demo.Model.EntityModels;

namespace Demo.Business.EntityServices.Concrete {
	public abstract class BasePersonService : IBaseService<Person> {
		protected IPersonData data = Demo.Data.NinjectFactory.Get<IPersonData>();
        
		/// <summary>
        /// Insert new Person
        /// </summary>
        /// <param name="t">Person</param>
        /// <param name="useTransaction">This action  will use transaction?</param>
       	/// <returns>ID of inserted Person</returns>
		public int Insert(Person t)
        {
			return data.Insert(t);
        }
		
		/// <summary>
        /// Update Person
		/// </summary>
        /// <param name="t">Person</param>
        /// <param name="useTransaction">This action  will use transaction?</param>
        /// <returns>Number of items updated</returns>
 		public int Update(Person t)
        {
			return data.Update(t);
        }

		/// <summary>
        /// Delete Person by primary keys
        /// </summary>
        /// <param name="useTransaction">This action  will use transaction?</param>
        /// <param name="keys">Array of primary keys</param>
        /// <returns>Number of items deleted</returns>
        public int Delete(params object[] keys)
        {
			return data.Delete(keys);
        }
		
		/// <summary>
        /// Get list of Person
        /// </summary>
        /// <param name="orderBy">Order by string, ex: "PRODUCT_ID ASC"</param>
        /// <param name="page">Index of current page</param>
        /// <param name="pageSize">Number of items  one page</param>
        /// <param name="totalRecords">Total number of items all pages</param>
        /// <returns>List of Person</returns>
		public List<Person> GetList()
        {
			int totalRecords = 0;
			return GetList("id ASC", 0, 0, out totalRecords);
            
        }
		
		/// <summary>
        /// Get list of Person
        /// </summary>
        /// <param name="orderBy">Order by string, ex: "PRODUCT_ID ASC"</param>
        /// <returns>List of T</returns>
        public List<Person> GetList(string orderBy)
        {
			int totalRecords = 0;
			return GetList(orderBy, 0, 0, out totalRecords);
            
        }
		
		/// <summary>
        /// Get list of Person
        /// </summary>
        public List<Person> GetList(string orderBy, int page, int pageSize, out int totalRecords)
        {
			totalRecords = 0;
			return data.GetList(orderBy, page, pageSize, out totalRecords);
        }
		
		/// <summary>
        /// Get Person by primary keys
        /// </summary>
        /// <param name="keys">Array of primary keys</param>
        /// <returns>Person </returns>
       	public Person Get(params object[] keys)
        {
			return data.Get(keys);
        }

	}
}